package org.groovymud.object;

/**
 * Copyright 2008 Matthew Corby-Eaglen
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

import org.apache.log4j.Logger;
import org.groovymud.engine.event.observer.Observable;
import org.groovymud.object.alive.Alive;
import org.groovymud.object.registry.MudObjectAttendant;
import org.groovymud.object.registry.Registry;
import org.groovymud.object.views.View;
import org.groovymud.shell.command.CommandInterpreter;

import java.util.List;

/**
 * a bog standard, unamed mud object
 *
 * @author corbym
 */
class MudObjectWithNameAndDescription extends Observable implements MudObject, Cloneable {

    private static final Logger logger = Logger.getLogger(MudObjectWithNameAndDescription.class);

    private String name;
    private String description;
    private String shortDescription;

    private List<String> shortNames;

    private boolean articleRequired = true;

    private ObjectLocation objectLocation; // where this bean can be loaded from
    private transient Container currentContainer;
    private ObjectLocation containerLocation; // metadata on the container //
    private View view;

    private transient Registry registry;


    private transient MudObjectAttendant mudObjectAttendant;
    private transient CommandInterpreter interpreter;

    public void initialise() {

    }

    public void heartBeat() {

    }

    public void addShortName(String shortName) {
        shortNames.add(shortName);
        if (registry != null && shortName != null) {
            logger.info("re-registering object with new shortName:" + shortName);
            registry.update(this);
        }
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
        if (registry != null && name != null) {
            logger.info("re-registering object with new name:" + name);
            registry.update(this);
        }
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description1) {
        this.description = description1;
    }

    public List<String> getShortNames() {
        return shortNames;
    }

    public void setShortNames(List<String> shortNames1) {
        this.shortNames = shortNames1;
    }

    public String getShortDescription() {
        return shortDescription;
    }

    public void setShortDescription(String shortDescription) {
        this.shortDescription = shortDescription;
    }

    public boolean isArticleRequired() {
        return articleRequired;
    }

    public void setArticleRequired(boolean articleRequired1) {
        this.articleRequired = articleRequired1;
    }

    public ObjectLocation getObjectLocation() {
        return objectLocation;
    }

    public void setObjectLocation(ObjectLocation objectLocation1) {
        this.objectLocation = objectLocation1;
    }

    public Container getCurrentContainer() {
        return currentContainer;
    }

    public void setCurrentContainer(Container currentContainer1) {
        this.currentContainer = currentContainer1;
    }

    public ObjectLocation getContainerLocation() {
        return containerLocation;
    }

    public void setContainerLocation(ObjectLocation containerLocation1) {
        this.containerLocation = containerLocation1;
    }

    public View getView() {
        return view;
    }

    public void setView(View view1) {
        this.view = view1;
    }

    public Registry getRegistry() {
        return registry;
    }

    public void setRegistry(Registry registry1) {
        this.registry = registry1;
    }

    public CommandInterpreter getInterpreter() {
        return interpreter;
    }

    public void setInterpreter(CommandInterpreter interpreter1) {
        this.interpreter = interpreter1;
    }

    public boolean doCommand(Alive mob, String command, String args) {
        return false;
    }

    public MudObjectAttendant getMudObjectAttendant() {
        return mudObjectAttendant;
    }

    public void setMudObjectAttendant(MudObjectAttendant mudObjectAttendant) {
        this.mudObjectAttendant = mudObjectAttendant;
    }

}
